1. Field of the Invention
The present invention relates to an emulator apparatus and an emulation method that are capable of preserving pieces of information stored in registers and a memory on each execution of an instruction and allows a program fault to be analyzed with a high degree of efficiency.
2. Description of the Prior Art
FIG. 1 is a diagram showing the configuration of a conventional support system used in development of a program to be executed in a target system controlled by a microcomputer. Reference numeral 31 shown in the figure is a host computer. Reference numeral 33 is an emulator apparatus used as a support system for locating and correcting (i.e., debugging) errors in the program. As shown in the figure, the emulator apparatus 33 is connected to the host computer 31 by a communication cable 32. With the emulator apparatus 33, a written program can be executed without writing the program in a ROM. If a result of the execution of the program by means of a program execution function indicates that a target system denoted by reference numeral 34 does not work correctly, it is necessary to locate an error of the program and correct the error. Examples of the target system 34 which employs a microcomputer are a copy machine and an air conditioner. Reference numeral 35 is a probe for connecting the target system 34 to the emulator apparatus 33. Reference numeral 36 is a hard-disk unit for storing data of the host computer 31 and reference numeral 37 is a communication cable for exchanging data between the host computer 31 and the hard-disk unit 36.
The support system shown in FIG. 1 works as follows. First of all, a user invokes a piece of software known as debug software in the host computer 31 which is used for controlling the emulator apparatus 33. That is to say, the emulator apparatus 33 is controlled by the user by operating the debug software. It should be noted that, prior to the use of the emulator apparatus 33, the host computer 31 is used for developing programs.
For the reader's information, a procedure for developing a program is explained as follows.
First of all, in the development of a program to be executed on a microprocessor, the program is written in a formal language called a programming language. A program is written typically by using a word-processor (available in the market) run on the host computer 31. The written program is stored in a data file of the word-processor. Then, the program stored in the data file is converted by translating software known as a compiler or an assembler into machine-language information which can be executed readily by the microprocessor. The compiler is a software tool running on the host computer 31. The compiler reads out the written program from the data file of the word-processor as input data and creates the machine-language information as output data which represents the written program.
As described above, the emulator apparatus 33 is connected to the host computer 31 by the communication cable 32 for transmitting a command issued by the host computer 31 to the emulator apparatus 33 and exchanging data between the host computer 31 and the emulator apparatus 33. Also as described above, the emulator apparatus 33 is on the other hand connected to the target system 34 by the probe 35, one end of which is plugged into a socket for the microprocessor on the board of the target system 34.
Next, an internal circuit of the conventional emulator apparatus is explained by referring to a diagram showing the configuration of the internal circuit.
FIG. 2 is a diagram showing the configuration of the conventional emulator apparatus. Reference numeral 11 shown in the figure is a microcomputer and reference numeral 12 is an emulation memory unit for storing program information received from the host computer 31 by way of a communication interface unit 17 and a monitor circuit 15. Reference numeral 14 is a trace circuit for monitoring information on a system bus 13 through a bus control circuit 16 and for forming a judgment as to whether or not a bus access satisfying a trace condition set in advance by the monitor circuit 15 is made. If a bus access satisfying a trace condition is detected, the trace circuit 14 notifies the monitor circuit 15 of the fact that a trace condition is satisfied. The bus control circuit 16 is a central circuit for controlling the other blocks in the emulator apparatus 33. The bus control circuit 16 interprets a command issued by a user by way of the host computer 31 and carries out processing requested by the command. Reference numeral 18 is a trace memory unit for storing trace information when receiving a signal requesting preservation of the trace information from the trace circuit 14.
The emulator apparatus operates as follows. First of all, information on a program received from the host computer 31 by way of the communication interface unit 17 and the monitor circuit 15 is stored in the emulation memory unit 12. Next, when trace information is to be preserved, the user sets a trace condition in the trace circuit 14 in advance prior to the execution of the program stored in the emulation memory unit 12. Then, the program is executed by the microcomputer 11 which is used for emulation purposes. As a signal requesting preservation of trace information is received from the trace circuit 14, the trace memory unit 18 stores the trace information. The trace circuit 14 monitors information on a system bus 13 through the bus control circuit 16, forming a judgment as to whether or not a bus access satisfying a trace condition set in advance by the monitor circuit 15 is made. If a bus access satisfying a trace condition is detected, the trace circuit 14 notifies the monitor circuit 15 of the fact that a trace condition is satisfied.
Since the conventional emulator apparatus has the configuration described above, trace information preserved in the trace memory unit 18 comprises only data and control signals flowing through the system bus 13. Records of changes in contents of data and control registers of the CPU in the target system 34 are not preserved.
For this reason, even though the contents of a memory of the CPU in the target system 34 can be restored, it is impossible to restore the contents of data registers and control registers. As a result, once an instruction has been executed, a state prior to the execution of the instruction can not be restored.
It is thus necessary to analyze trace information by visual observation in order to locate an error of a program, giving rise to a problem that it takes a lot of time to locate and correct the program error.
In addition, in the case of an emulator apparatus 33 with no trace function, it is necessary to search a program for the location of an error by step execution. In this case, however, when it is desired to return to a prior state before re-execution can be carried out, it is necessary to execute the program from the beginning. As a result, such an emulator apparatus 33 also has a problem that it takes a lot of time to locate and correct an error of the program.